//
//  HLNetworking.h
//  weibo-OC
//
//  Created by 黄力 on 15/12/21.
//  Copyright © 2015年 HLTest. All rights reserved.
//

#import <AFNetworking/AFNetworking.h>

//声明一个协议
@protocol HLNetworkingCoverDelegate <NSObject>

//AFN的GET和POST实际上都是在调用该方法,用一个协议来欺骗编译器通过编译,调用的过程中就会去调用父类中的该方法
//这是一个AFN的私有方法
@optional
- (NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method
                                       URLString:(NSString *)URLString
                                      parameters:(id)parameters
                                  uploadProgress:(void (^)(NSProgress *uploadProgress)) uploadProgress
                                downloadProgress:(void (^)(NSProgress *downloadProgress)) downloadProgress
                                         success:(void (^)(NSURLSessionDataTask *, id))success
                                         failure:(void (^)(NSURLSessionDataTask *, NSError *))failure;

@end

//重命名block代码块
typedef void (^FinshedBlock)(id resultData, NSError *error);

@interface HLNetworking : AFHTTPSessionManager<HLNetworkingCoverDelegate>

//创建单例的方法
+ (instancetype)sharedNetworing;

//发送网络请求
- (void)sendHTTPRequestWithHTTPMethod:(NSString *)HTTPMethod withUrlStr:(NSString *)urlStr withParameters:parameters withFinshedBlock: (FinshedBlock) finshedBlock;
//上传图片
- (void)uploadImageDataWithUrlStr:(NSString *)urlStr withParameters:(id)parameters withImageData:(NSData *)imageData withFinshBlock:(FinshedBlock) finshedBlock;

@end
